Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ec2_launch_template to correctly remove all None types #438

Conversation

stefanhorning
Copy link
Contributor

@stefanhorning stefanhorning commented Feb 23, 2021

fixes issue #230

SUMMARY

When leaving module params blank the module would send None types in it's nested dics structure to boto, which then led to errors
This PR is fixing this by recursively removing all None types from the entire dict passed to boto.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

ec2_launch_template module

ADDITIONAL INFORMATION

Run this task for example with and without the fix and you will see what I mean:

    - name: Create Launch Template to test Ansible ec2_launch_template module code
      ec2_launch_template:
        name: test-ansible-ec2-launch-template-module
        image_id: ami-XXX
        security_group_ids:
          - sg-XXXX
        instance_type: c5.large
        key_name: my_key
        instance_market_options:
          market_type: spot
          spot_options:
            max_price: 0.5
            spot_instance_type: one-time
            instance_interruption_behavior: terminate
        block_device_mappings:
          - device_name: /dev/sda1
            ebs:
              volume_type: gp2
              volume_size: 10
              delete_on_termination: true
              encrypted: true
          - device_name: /dev/sdb
            ebs:
              volume_type: gp2
              volume_size: 200
              delete_on_termination: true
              encrypted: true
        monitoring:
          enabled: false
        region: us-east-1
        state: present
      register: launch_template_result

    - name: Output result
      debug:
        var: launch_template_result

Of course replace XXX with your IDs. Find more test cases in #230

@stefanhorning
Copy link
Contributor Author

Actually there is a second issue here #251 which is a duplicate of #230. Thus this PR fixes both issues.

@ansibullbot
Copy link

@ansibullbot ansibullbot added bug This issue/PR relates to a bug community_review has_issue module module needs_triage plugins plugin (any type) labels Feb 23, 2021
@ansibullbot ansibullbot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed community_review labels Feb 23, 2021
@markuman
Copy link
Member

markuman commented Mar 1, 2021

It's big chaos about the None values...the idea was a module_utils function in amazon.aws, that can be used all over the aws collection.
I guess you should close your merge request and become an active reviewer for this PR ansible-collections/amazon.aws#262 to speed things up.

@stefanhorning
Copy link
Contributor Author

yes, I realized that by now. Just missed the final PR at first :)

alinabuzachis pushed a commit to alinabuzachis/community.aws that referenced this pull request May 25, 2022
Add support for ipv6 addresses

SUMMARY
Allow amazon.aws.aws_service_ip_ranges to return only IPv6 addresses with setting ipv6_prefixes=True
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
amazon.aws.aws_service_ip_ranges
ADDITIONAL INFORMATION

vars:
  rt53_ranges: "{{ lookup('aws_service_ip_ranges', region='us-west-2', service='ROUTE53_HEALTHCHECKS', ipv6_prefix=True, wantlist=True) }}"
tasks:

- name: "use list return option and iterate as a loop"
  debug: msg="{% for x in rt53_ranges %}{{ x }} {% endfor %}"
# "2600:1f14:7ff:f800::/56,2600:1f14:fff:f800::/56"

Closes ansible-collections#438

Reviewed-by: None <None>
Reviewed-by: Mark Chappell <None>
Reviewed-by: None <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug has_issue module module needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR needs_triage plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants